home *** CD-ROM | disk | FTP | other *** search
- Path: fido.asd.sgi.com!austern
- From: Roman Lechtchinsky <wolfro@cs.tu-berlin.de>
- Newsgroups: comp.std.c++
- Subject: Re: Is RTTI required if polymorphic constructor exists
- Date: 18 Apr 1996 09:42:40 PDT
- Organization: Technical University of Berlin
- Approved: austern@isolde.mti.sgi.com
- Message-ID: <31761AD4.6173@cs.tu-berlin.de>
- References: <4kng7f$kt9@nuscc.nus.sg> <4kr21b$6ar@mulga.cs.mu.OZ.AU> <4l30l2$31v@nuscc.nus.sg> <31755193.113D@cyberspy.com>
- NNTP-Posting-Host: isolde.mti.sgi.com
- X-Original-Date: Thu, 18 Apr 1996 12:35:00 +0200
- X-Mailer: Mozilla 2.0 (Win95; I)
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBVAwUBMXZxAUy4NqrwXLNJAQEmFwH+Og3xwAXoI2+0KorWQ1YVvgV1YqvjIKin
- 86YCm6rezKfXZ/xO9LSpesqD0n+M8eKb+68IeQ3AJ7aZZsblY9EMBw==
- =4FJN
- Originator: austern@isolde.mti.sgi.com
-
- Rich Paul wrote:
- >
- > Satrajit Sujit Ghosh wrote:
- > >
- > > Would it be possible to illustrate efficient, convenient and
- > > pratical use of the RTTI functions?
- > >
- >
- > Hmmm ... well, this comes in handy:
- >
- > ostream &operator << ( ostream &os, const exception &e )
- > {
- > return os << endl
- > << "Exception: " << typeid(e).name() << endl
- > << "Message: " << e.what() << endl;
- > };
- >
- > Since the typename of the exception carries some of the most relevent
- > information about the exception, why not use it ... of course, the
- > same thing could be done with virtual functions.
- >
-
- Except that typeid(e).name() returns an implementation-defined value which (
- if my reading of the April DWP is correct ) is not necessarily a
- null-terminated string. It might even be an invalid pointer so that the above
- function wouldn't work at all. I don't know if this has already been done but
- if not - why not guarantee that the pointer is at least valid?
-
- Bye
-
- Roman
- ---
- [ comp.std.c++ is moderated. To submit articles: Try just posting with your
- newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
- comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
- Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
- Comments? mailto:std-c++-request@ncar.ucar.edu
- ]
-